import os
import platform

class LinuxEnv:
    @staticmethod
    def get_desktop_env():
        """检测桌面环境"""
        de = os.getenv("XDG_CURRENT_DESKTOP", "").lower()
        if "deepin" in de:
            return "deepin"
        elif "kde" in de:
            return "kde"
        elif "gnome" in de:
            return "gnome"
        return "other"

    @staticmethod
    def is_deepin_v23():
        """判断是否为Deepin V23"""
        if platform.system() != "Linux":
            return False
        try:
            with open("/etc/os-release") as f:
                return 'VERSION_ID="23"' in f.read() and 'DEEPIN' in f.read()
        except:
            return False